package test;

import java.util.*;
class WareFactory {
    private final ArrayList<KitchenWare> Wares = new ArrayList<>();
    private int totalNum = 0;

    public WareFactory() {
        KitchenWare nd1 = new bowl("饭碗");
        Wares.add(nd1);
        KitchenWare nd2 = new cup("杯子");
        Wares.add(nd2);
    }
    public KitchenWare getKitchenWare(String type) {
        if(type.equalsIgnoreCase("饭碗")) {
            totalNum++;
            return Wares.get(0);
        } else if(type.equalsIgnoreCase("杯子")) {
            totalNum++;
            return Wares.get(1);
        } else {
            return null;
        }
    }
    public int getTotalWare() {
        return Wares.size();
    }
    public int gettotalNum() {
        return totalNum;
    }
}
interface KitchenWare {
//    public String getType();
    public void use();
}
class bowl implements KitchenWare {
    private String type;
    public bowl(String type) {
        this.type=type;
    }
    public String getType() {
        return this.type;
    }
    public void use() {
        System.out.println("使用的厨具是：" + this.type);
    }
}
class cup implements KitchenWare {
    private String type;
    public cup(String type) {
        this.type=type;
    }
    public String getType() {
        return this.type;
    }
    public void use() {
        System.out.println("使用的厨具是：" +this.type);
    }
}
public class Client2010 {
    public static void main(String[] args) {
        KitchenWare kw1,kw2,kw3,kw4;
        WareFactory df=new WareFactory();
        kw1=df.getKitchenWare("饭碗");
        kw1.use();
        kw2=df.getKitchenWare("饭碗");
        kw2.use();
        kw3=df.getKitchenWare("杯子");
        kw3.use();
        kw4=df.getKitchenWare("杯子");
        kw4.use();
        System.out.println("厨具种类:" + df.getTotalWare());
        System.out.println("生成的厨具数:" + df.gettotalNum());
    }

    public static void main1(String[] args) {
//        A a = new A();
//        A b = new B();
//        // 静态方法和类绑定 --- 编译类型
//        a.fun();// A的static fun
//        b.fun();// A的static fun
//        B.fun();// B的static fun

        Father a = new A();
        a.fun();// Father的static fun
        Father b = new B();
        b.fun();// Father的static fun
    }
}

class Father{
    static void fun(){
        System.out.println("Father的static fun");
    }
}
class A extends Father{
    static void fun(){
        System.out.println("A的static fun");
    }
}

class B extends A{
    static void fun(){
        System.out.println("B的static fun");
    }
}
